//
//  VMCToolView.m
//  vmcshop
//
//  Created by toggle on 15/7/17.
//  Copyright (c) 2015年 idongler. All rights reserved.
//

#import "VMCToolView.h"

@interface VMCToolView ()
{
	ToolBlock _toolBlock;
}
@end

@implementation VMCToolView

- (instancetype)initWithFrame:(CGRect)frame withBlock:(ToolBlock)block
{
	self = [super initWithFrame:frame];
	if (self)
	{
		_toolBlock = block;
		self.backgroundColor = RGB(241, 241, 241);
		_topLine = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(frame), 0.3)];
		_topLine.backgroundColor = [UIColor lightGrayColor];
		[self addSubview:_topLine];

		_actionBtn = [[UIButton alloc] initWithFrame:CGRectMake(CGRectGetWidth(frame)-100-10, CGRectGetHeight(frame)/2-40/2, 100, 40)];
		_actionBtn.backgroundColor = RGB(185, 52, 25);
		NSAttributedString *str = [[NSAttributedString alloc] initWithString:@"立即支付" attributes:@{NSForegroundColorAttributeName:[UIColor whiteColor],NSFontAttributeName:[UIFont systemFontOfSize:14.0f]}];
		[_actionBtn setAttributedTitle:str forState:UIControlStateNormal];
		[_actionBtn addTarget:self action:@selector(actionBtn:) forControlEvents:UIControlEventTouchUpInside];
		_actionBtn.layer.masksToBounds = YES;
		_actionBtn.layer.cornerRadius = 5.0f;
		[_actionBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
		[self addSubview:_actionBtn];

		_titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, CGRectGetHeight(frame)/2-40/2, CGRectGetMinX(_actionBtn.frame)-10, 40)];
		_titleLabel.text = @"应付总额：￥0.00";
		_titleLabel.textAlignment = NSTextAlignmentLeft;
		_titleLabel.font = [UIFont systemFontOfSize:14.0f];
		_titleLabel.backgroundColor = [UIColor clearColor];
		[self addSubview:_titleLabel];

	}
	return self;
}
- (void)actionBtn:(UIButton *)btn
{
	_toolBlock(_titleLabel,btn);
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
